package cn.fan.job;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class GatherStoreJob {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Scheduled(cron = "${autotask.cron.test}")
    private void test(){
        System.out.println("task test!");
    }

    @Scheduled(cron = "${autotask.cron.gatherStore}")
    private void gatherStore(){
        String exchange="fund.direct";
        String key = "fund";
        String message="synchro"; // 增量同步，发什么消息无所谓
        rabbitTemplate.convertAndSend(exchange,key,message);
    }

    // 全量同步
    @Scheduled(cron = "${autotask.cron.gatherStoreAll}")
    private void gatherStoreAll(){
        String exchange="fund.direct";
        String key = "fund";
        String message="synchroAll"; // 增量同步，发什么消息无所谓
        rabbitTemplate.convertAndSend(exchange,key,message);
    }

}
